package com.jxzn.locust.support;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;

public enum SessionItem {

    ACCOUNT,

    USER_ID;

    public static String getAccount(HttpServletRequest request) {
        Object account = request.getSession().getAttribute(ACCOUNT.name());
        return null == account ? StringUtils.EMPTY : account.toString();
    }

    public static int getUserId(HttpServletRequest request) {
        Object userId = request.getSession().getAttribute(USER_ID.name());
        return null == userId ? 0 : NumberUtils.toInt(userId.toString(), 0);
    }
}
